package light.head.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import light.head.constant.Sys;

import org.hibernate.annotations.Formula;
/**
 * 车辆信息
 *
 */
@Entity
@Table
public class Vehicle implements Serializable {
	
	
	private static final long serialVersionUID = -6190953674952297165L;
	
	
	private Integer code;
	private String name;						// 车辆名称
	private String plate;						// 车牌号
	private Integer price;						// 价格
	private Boolean deleted = false;			// 是否删除 
	private Integer cu;							// 创建人编号
	private Date ct;							// 创建时间
	private Byte status = Sys.B_TWO;			// 状态(1.使用中  2.空闲  3.维修中  4.停用）
	private String un;							// 使用人
	private Integer vtc;						// 车辆类型编号
	private Integer oc;							// 所属机构
	
	
	//@Formula
	private String on;
	private String cn;
	private String vtn;
	
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column(length = 50)
	public String getName() {
		return name;
	}
	@Column
	public String getPlate() {
		return plate;
	}
	@Column
	public Integer getPrice() {
		return price;
	}
	@Column
	public Integer getVtc() {
		return vtc;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Byte getStatus() {
		return status;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public String getUn() {
		return un;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT v.name FROM VehicleType v WHERE v.code = vtc)")
	public String getVtn() {
		return vtn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	
	
	
	
	
	
	
	
	

	public void setUn(String un) {
		this.un = un;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setPlate(String plate) {
		this.plate = plate;
	}
	public void setPrice(Integer price) {
		this.price = price;
	}
	public void setVtc(Integer vtc) {
		this.vtc = vtc;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setStatus(Byte status) {
		this.status = status;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public void setVtn(String vtn) {
		this.vtn = vtn;
	}

	
	

}
